using System.Collections.Generic;
using System.Linq.Expressions;
using System.Globalization;

namespace System.Web.Mvc.Html
{
    public static class ExtensionMethods
    {
        #region DropdownList

        public static MvcHtmlString DropDownList(this HtmlHelper helper, 
            string name, Dictionary<int, string> dictionary)
        {
            var selectListItems = new SelectList(dictionary, "Key", "Value");
            return helper.DropDownList(name, selectListItems);
        }

        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> helper,
            Expression<Func<TModel, TProperty>> expression, Dictionary<int, string> dictionary)
        {
            var selectListItems = new SelectList(dictionary, "Key", "Value");
            return helper.DropDownListFor(expression, selectListItems);
        }

        #endregion

        #region LabelExtensions

        public static string Label(this HtmlHelper helper, string target, string text)
        {
            return string.Format(CultureInfo.CurrentCulture, "<label for='{0}'>{1}</label>", target, text);
        }
        #endregion
    }
}